import zipfile
from time import time
# from threading import Thread
from multiprocessing import Process
zFile = zipfile.ZipFile('python msoffice.zip')




s = open('res.txt','r')
content = s.readlines() #分行读取字典
dics = int(len(content)/100)
 
print('当前字典中变量个数为: %s' % str(len(content)))
 
print("字典将被分割为 %s 份" % str(dics))
 
group = []  #字典每行独立化,写入元组
for h in range(0,len(content)):
    password = str(content[h]).strip('\n')  #剔除换行符
    group.append(password)
 


 
start = time()



def run2(a,b,c):
    for i in range(a*int(dics/c), b*int(dics/c)):
        new_group = []
        for k in range(i * 100, (i + 1) * 100):
            new_group.append(group[k])
            k += 1
        print("正在进行第 %s 组字典爆破" % str(i + 1))
        for each in new_group:

            try:
                zFile.extractall(pwd=bytes(each.strip(), 'utf-8'))
                print('the password is:' + each + '\n')
            except:
                pass





# for i in range(5):
#     t1 = Thread(target=run1(),args=("i+1",))
# # t2 = Thread(target=run2(),args=("t2",))
#     t1.start()  #启动线程
# # t2.start()


if __name__ == '__main__':
    for i in range(5):
        pi = Process(target = run2,args=(i,i+1,5,))
        pi.start()


    print("执行完毕")
    print('time:%s'%(time()-start))
